home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2005 July / Macworld CD 17.05.iso / Data / Main.dxr / 00062_DownArrow obj.ls < prev    next >
Encoding:
Text File  |  2000-02-28  |  3.4 KB  |  81 lines

  1. property upmember, downmember, hilitemember, target, thumb, scrollBar
  2. global viewingTop, viewingBottom
  3.  
  4. on new me
  5.   return me
  6. end
  7.  
  8. on getPropertyDescriptionList me
  9.   description = [:]
  10.   addProp(description, #upmember, [#default: "DownArrow", #format: #string, #comment: "Pict for Regular state:"])
  11.   addProp(description, #downmember, [#default: "DownArrowDown", #format: #string, #comment: "Pict for Down state:"])
  12.   addProp(description, #hilitemember, [#default: "DownArrowRoll", #format: #string, #comment: "Pict for Roll state:"])
  13.   addProp(description, #target, [#default: 0, #format: #integer, #comment: "The sprite to move:"])
  14.   addProp(description, #thumb, [#default: 0, #format: #integer, #comment: "The sprite of the thumb:"])
  15.   addProp(description, #scrollBar, [#default: 0, #format: #integer, #comment: "The sprite of the scrollbar:"])
  16.   addProp(description, #ScrollSpeed, [#default: 1, #format: #integer, #comment: "Scroll Speed(pixels/Scroll):"])
  17.   return description
  18. end
  19.  
  20. on getBehaviorDescription me
  21.   return "Modified Button Object for the down arrow on a scrollbar"
  22. end
  23.  
  24. on beginSprite me
  25.   me.upmember = the member of sprite me.spriteNum
  26.   case sprite(me.scrollBar).boundsRect of
  27.     "Fixed":
  28.       viewingTop = the top of sprite sprite(me.scrollBar).uparrow
  29.       viewingBottom = the bottom of sprite sprite(me.scrollBar).dnarrow
  30.     "Stage":
  31.       viewingTop = 0
  32.       viewingBottom = the stageBottom - the stageTop
  33.     "Custom":
  34.       viewingTop = the top of sprite sprite(me.scrollBar).box
  35.       viewingBottom = the bottom of sprite sprite(me.scrollBar).box
  36.   end case
  37. end
  38.  
  39. on mouseDown me
  40.   set the member of sprite the spriteNum of me to member(me.downmember)
  41.   thePercent = 0
  42.   repeat while the stillDown
  43.     if (the locV of sprite me.thumb + me.ScrollSpeed) <= (the bottom of sprite me.scrollBar - (member(the memberNum of sprite sprite(me.thumb).spriteNum).height / 2)) then
  44.       set the locV of sprite the thumb of me to the locV of sprite me.thumb + me.ScrollSpeed
  45.       v = the locV of sprite me.thumb
  46.       H = member(the memberNum of sprite sprite(me.thumb).spriteNum).height / 2
  47.       realT = the top of sprite me.thumb
  48.       t = the top of sprite me.scrollBar + H
  49.       b = the bottom of sprite me.scrollBar - H
  50.       H2 = member(the memberNum of sprite sprite(me.scrollBar).spriteNum).height - member(the memberNum of sprite sprite(me.thumb).spriteNum).height
  51.       targetOffset = member(the memberNum of sprite sprite(me.target).spriteNum).height / 2
  52.       scrollTop = viewingTop + targetOffset
  53.       scrollBottom = viewingBottom - targetOffset
  54.       thePercent = float(v - t) / (b - t)
  55.       v = integer(thePercent * (scrollBottom - scrollTop)) + viewingTop + targetOffset
  56.       set the locV of sprite the target of me to v
  57.       updateStage()
  58.       next repeat
  59.     end if
  60.     H = member(the memberNum of sprite sprite(me.thumb).spriteNum).height / 2
  61.     b = the bottom of sprite me.scrollBar - H
  62.     targetOffset = member(the memberNum of sprite sprite(me.target).spriteNum).height / 2
  63.     scrollBottom = viewingBottom - targetOffset
  64.     set the locV of sprite the thumb of me to b
  65.     set the locV of sprite the target of me to scrollBottom
  66.     exit repeat
  67.   end repeat
  68. end
  69.  
  70. on mouseUp me
  71.   set the member of sprite the spriteNum of me to member(me.hilitemember)
  72. end
  73.  
  74. on mouseEnter me
  75.   set the member of sprite the spriteNum of me to member(me.hilitemember)
  76. end
  77.  
  78. on mouseLeave me
  79.   set the member of sprite the spriteNum of me to member(me.upmember)
  80. end
  81.